Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various smaller bugfixes in tests #870

Merged
merged 20 commits into from
Jun 20, 2024
Merged

Conversation

fknorr
Copy link
Contributor

@fknorr fknorr commented Feb 17, 2024

This PR fixes a bunch of discrepancies with the SYCL spec and minor bugs and ambiguities that surfaced when we attempted to build the CTS against SimSYCL.

Some of these issues might not be visible when building against a SYCL implementation (such as DPC++) that implements non-standard type conversions, member functions or other behavior.

In individual commits:

  • test_accessor: get_multi_ptr() is only defined for device- and local accessors
  • test_accessor_legacy: legacy accessors do not have member function size()
  • test_atomic_ref: Typo in function name memory_scope_is_suppoted
  • test_atomic_ref_stress: id<1> == int is ambiguous
  • test_device_info: info::device::image_max_array_size is not part of the Spec
  • test_device_info: info::device::opencl_c_version is not part of the Spec
  • test_device_selector: sycl::runtime_error is not part of the Spec
  • test_exceptions: sycl::exception is not default-constructible
  • test_hierarchical: sycl::id is not convertible to sycl::range (adressed by rebase)
  • test_id: sycl::id<1> - 1 is ambiguous
  • test_kernel: remove template from non-dependent expression
  • test_marray: marray<bool> does not have operator++/--
  • test_namespace: Avoid multiple definitions of kernel names
  • test_scalars: Regex typo in CMakeLists.txt
  • test_vector_load_store: sycl::vec cannot load/store from accessor or load from non-const multi_ptr
  • test_vector_operators: vec<bool> does not provide operator++/--
  • util: Call to erase_if is ambiguous with C++20

@fknorr fknorr requested a review from a team as a code owner February 17, 2024 15:53
@CLAassistant
Copy link

CLAassistant commented Feb 17, 2024

CLA assistant check
All committers have signed the CLA.

@steffenlarsen
Copy link
Contributor

Thank you for going through all these bugs and addressing them! It makes me wonder if some of these should be part of the spec, simply for usability.
@gmlueck @AerialMantis @keryell @illuhad @tomdeakin - Tagging for awareness.

@bader bader added the Agenda To be discussed during a SYCL committee meeting label Feb 20, 2024
Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a ride!

@@ -58,8 +58,23 @@ void test_accessor_methods(const AccT &accessor,
#endif
}

template<typename Accessor>
extern const sycl::target accessor_target_v;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this extern definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the base template that's being specialized below. For a variable template marking it extern allows me to omit the (invalid) definition and cause a compiler error when it's used in a constexpr context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not. :-)

fail_for_accessor<T, dims, mode, target>(log, typeName,
"accessor does not return the correct count");
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the problem here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests the legacy accessor<target::local> specialization, which does not have a size() member.

@@ -172,15 +172,15 @@ class aquire_release {
refA.store(0);
refB.store(0);
sycl::group_barrier(item.get_group());
if (item.get_local_id() == 0) {
if (item.get_local_id() == sycl::id(0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@AlexeySachkov AlexeySachkov Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And that is half of the problem, because id is also implicitly convertible to size_t. See godbolt. If you switch to gcc and member operation you will get a bit more detailed error message. But I was also surprised by this, apparently I'm not enough familiar with those overload resolution rules.

In our implementation we use some hackery to avoid ambiguity here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So either the special-casing needs to be in the spec, or this explicit construction is correct.

x = refA.load();
refB.store(1);
} else {
y = refB.load();
refA.store(1);
}
sycl::group_barrier(item.get_group());
if (item.get_local_id() == 0)
if (item.get_local_id() == sycl::id(0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem.

@@ -194,8 +194,14 @@ TEST_CASE("Constructors for sycl::exception with sycl::errc error codes",
check_exception(copy, errcode, sycl::sycl_category());
}
SECTION("operator=(const exception& other)") {
// sycl::exception is not default-constructible, so explicitly construct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

static sycl::range<1> id_to_range(sycl::id<1> id) {
return sycl::range<1>(id[0]);
}
static sycl::range<2> id_to_range(sycl::id<2> id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static sycl::range<2> id_to_range(sycl::id<2> id) {
static sycl::range<2> to_range(sycl::id<2> id) {

since the id is clear as the parameter?

Copy link
Contributor Author

@fknorr fknorr Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete now because it has been fixed on SYCL-2020 branch in the meantime. Removed entirely.

@@ -239,7 +239,8 @@ TEMPLATE_TEST_CASE_SIG("id can be implicitly conversion-constructed from item",
q.submit([r, &result_buf](sycl::handler& cgh) {
sycl::accessor result{result_buf, cgh, sycl::write_only};
cgh.parallel_for<kernel_id<D>>(r, [=](sycl::item<D> itm) {
if (itm.get_id() == id<D>{r} - 1) {
// `ul` suffix is necessary to resolve ambiguity for id<1>
if (itm.get_id() == id<D>{r} - 1ul) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why l?
Just u does not work?
The real type would be uz but it is C++23.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but size_t is at least unsigned long on all relevant architectures, no?

named_type_pack<op_upos, op_uneg, op_pre_inc, op_pre_dec, op_lnot,
op_bnot>::generate("unary +", "unary -", "pre ++",
"pre --", "!", "~");
static const auto unary_operators = make_unary_operators();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a good opportunity for a lambda with immediate invocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is!

Comment on lines 852 to 851
if (!std::is_same_v<DataT, bool>) {
static const auto unary_post_operators =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!std::is_same_v<DataT, bool>) {
static const auto unary_post_operators =
if constexpr (!std::is_same_v<DataT, bool>) {
constexpr auto unary_post_operators =

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static const must remain because it's not a literal type (clang error)

}
// The standard does not require ++ and -- (either prefix or postfix) for the
// bool type, so we skip tests for these operators if DataT is bool. This cannot
// be done via `if constexpr` because the type is not a dependent type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a design bug of the test relying too much on Python to do the metaprogramming instead of leaving the instantiation to C++?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second.

@bader bader removed the Agenda To be discussed during a SYCL committee meeting label Feb 29, 2024
@tomdeakin
Copy link
Contributor

The SYCL WG discussed this, and the review process should continue to merge this. We will then want to follow up on the new features proposed to possibly include in the spec. So, please continue to review and update this PR based on those reviews. Thanks!

@bader
Copy link
Contributor

bader commented Feb 29, 2024

It makes me wonder if some of these should be part of the spec, simply for usability.

@steffenlarsen, could you open issues in SYCL-Docs project for the items which you think should be part of the spec, please?

@steffenlarsen
Copy link
Contributor

It makes me wonder if some of these should be part of the spec, simply for usability.

@steffenlarsen, could you open issues in SYCL-Docs project for the items which you think should be part of the spec, please?

Opened KhronosGroup/SYCL-Docs#540 and KhronosGroup/SYCL-Docs#539.

AlexeySachkov pushed a commit to intel/llvm that referenced this pull request Apr 15, 2024
As mentioned in the CTS pull request
KhronosGroup/SYCL-CTS#870, two device info
descriptors, namely `info::device::image_max_array_size` and
`info::device::opencl_c_version`, have been deprecated and no longer
exist in the SYCL 2020 specification. But they still exist in our
implementation, so I'm setting up deprecation warnings for them. Also a
related test case has been revised to remove the usage of
`info::device::opencl_c_version`.

Also `info::device::usm_system_allocator` has been replaced and marked
as deprecated 2+ years ago in PR #4007
and #9217 respectively. So I'm
cleaning up a few relevant code pieces in our code as well in this PR.

---------

Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
@fknorr
Copy link
Contributor Author

fknorr commented Jun 13, 2024

Rebased, which allowed me to drop one commit whose problem has been addressed on the target branch in the meantime.

@bader bader requested a review from keryell June 13, 2024 14:50
Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -58,8 +58,23 @@ void test_accessor_methods(const AccT &accessor,
#endif
}

template<typename Accessor>
extern const sycl::target accessor_target_v;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not. :-)

@bader
Copy link
Contributor

bader commented Jun 18, 2024

@fknorr, please, fix the formatting check.

@bader bader merged commit c9bd94a into KhronosGroup:SYCL-2020 Jun 20, 2024
8 checks passed
@fknorr fknorr deleted the various-fixes branch June 20, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants